﻿@model  Wlog.Web.Models.User.EditUser

@{
    Layout = "~/Views/Shared/_LayoutInternal.cshtml";
}

<div class="row">
    <h2>@Html.DisplayFor(model => model.DataUser.Username)</h2>
    @using (Html.BeginForm("EditUser", "Private", FormMethod.Post))
    {
        @Html.AntiForgeryToken()
        @Html.ValidationSummary(true)

        <fieldset>
            <legend></legend>
            @Html.HiddenFor(model=>model.DataUser.Id)
            @Html.HiddenFor(model=>model.DataUser.Password)
            @Html.HiddenFor(model=>model.DataUser.Username)
            

            <div class="form-horizontal">
                <div class="form-group">
                    @Html.LabelFor(model => model.DataUser.Username, new { @class = "col-lg-2 control-label" })
                    <div class="col-lg-10">
                        @Html.DisplayFor(model => model.DataUser.Username, new { @class = "form-control" })
                    </div>
                </div>
                <div class="form-group">
                    @Html.LabelFor(model => model.DataUser.Email, new { @class = "col-lg-2 control-label" })
                    <div class="col-lg-10">
                        @Html.EditorFor(model => model.DataUser.Email, new { @class = "form-control" })
                    </div>
                </div>
                <div class="form-group">
                    @Html.LabelFor(model => model.DataUser.IsAdmin, new { @class = "col-lg-2 control-label" })
                    <div class="col-lg-10">
                        @Html.EditorFor(model => model.DataUser.IsAdmin, new { @class = "form-control" })
                    </div>
                </div>
                <div class="form-group">
                    @Html.LabelFor(model => model.DataUser.CreationDate, new { @class = "col-lg-2 control-label" })
                    <div class="col-lg-10">
                        @Html.DisplayFor(model => model.DataUser.CreationDate, new { @class = "form-control" })
                    </div>
                </div>
                <div class="form-group">
                    @Html.LabelFor(model => model.DataUser.LastLoginDate, new { @class = "col-lg-2 control-label" })
                    <div class="col-lg-10">
                        @Html.DisplayFor(model => model.DataUser.LastLoginDate, new { @class = "form-control" })
                    </div>
                </div>
            </div>
            <div>
                <table class="table">
                    <tr>
                        <th>Application
                        </th>
                        <th>Role
                        </th>
                    </tr>
@*                    @foreach (var item in Model.Apps)
                    {
                        @Html.HiddenFor(model=>model.Apps)
                        <tr>
                            <td>
                                @Html.DisplayFor(model => item.Application.ApplicationName)
                                @Html.HiddenFor(model=>item.Application.IdApplication)
                            </td>
                            <td>
                                @Html.DropDownListFor(model => item.Role.Id, new SelectList(Model.RoleList, "Id", "RoleName", item.Role.Id))
                            </td>
                        </tr>
                    }*@
                    @for(int i=0;i<Model.Apps.Count();i++)
                    {
                        <tr>
                            <td>
                                @Html.DisplayFor(model => model.Apps[i].ApplicationName)
                                @Html.HiddenFor(model=>model.Apps[i].IdApplication)
                                @Html.HiddenFor(model=>model.Apps[i].ApplicationName)
                            </td>
                            <td>
                                @Html.DropDownListFor(model => model.Apps[i].RoleId, new SelectList(Model.RoleList, "Id", "RoleName", Model.Apps[i].RoleId))
                            </td>
                        </tr>
                    }
                </table>
            </div>

            <p>
                @Html.ActionLink("Back to List", "ListUsers", null, new { @class = "btn btn-success btn-list" })
               
                <input type="submit" value="Save" class="btn btn-warning pull-right btn-list"  />&nbsp;
                @Html.ActionLink("Delete User", "DeleteUser", new { Id = Model.DataUser.Id }, new { @class = "btn btn-danger pull-right btn-list" })
               
            </p>
        </fieldset>
    }

</div>

